//---------------------------------------------------------------------
//  This file is part of the Background Motion solution.
// 
//  Copyright (C) Mindscape (TM).  All rights reserved.
//  http://www.mindscape.co.nz
// 
//  THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//---------------------------------------------------------------------

using System;
using Microsoft.Practices.CompositeWeb;
using Mindscape.BackgroundMotion.Core;

namespace Mindscape.BackgroundMotion.Website
{
  /// <summary>
  /// The root of our application
  /// </summary>
  /// <remarks>
  /// We subclass the WebClientApplication from the Composite Web block which allows us to leverage that framework
  /// </remarks>
  public class WebApplication : WebClientApplication
  {
    /// <summary>
    /// Handles the BeginRequest event of the Application control and initializes the current ServiceLocator
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void Application_BeginRequest(object sender, EventArgs e)
    {
      ServiceLocator.Initialize(new CabServiceBroker(RootContainer.Services));
    }
  }
}